from tetris import *
from pca import *

class menu(object):

    def __init__(self):
        self.aff_menu()

    def aff_menu(self):
        self.master = Tk()
        self.master.title("Menu tetris PCA")
        self.j1 = Button(self.master, text="J1", command=self.j1)
        self.j2 = Button(self.master, text="J2", command=self.j2)
        self.x = Button(self.master, text="JX", command=self.jx)
        self.r = Button(self.master, text="Reconnait", command=self.rec)
        self.j1.pack()
        self.j2.pack()
        self.x.pack()
        self.r.pack()
        self.qui = Button(self.master, text="          Quitter         ", command=self.quitte)
        self.qui.pack()
        self.j1_res = []
        self.j2_res = []
        self.jx_res = []
        

    def j1(self):
        self.j1_res += [tetris()]
        
    def j2(self):
        self.j2_res += [tetris()]
        
    def jx(self):
        self.jx_res += [tetris()]
        
    def rec(self):
        fen_res = Tk()
        fen_res.title("Resultat de la PCA")
        recl = reconnait(self.j1_res,self.j2_res,self.jx_res)
        joueur = "le joueur x est : "+recl+" !"
        aff = Button(fen_res,text=joueur,command=fen_res.destroy)
        aff.pack()
        fen_res.mainloop()
        
    def quitte(self):
        self.master.destroy()
        
    def main(self):
        self.master.mainloop()


Men = menu ()
Men.main()
